#pragma once

#include <list>
#include <boost/random.hpp>

#include <boostext/typedefs.hpp>
#include <boostext/container/list.hpp>




struct test_list
{
private:

	typedef float                                          value_type;
	typedef boostext::list<value_type>                     list;
	typedef std::list<value_type>                          stdlist;

	typedef boost::mt19937                                 rng;
	typedef boost::uniform_real<value_type>                distribution;
	typedef boost::variate_generator<rng&, distribution>   die;

private:

	uint32 m_seed;

public:

	test_list();

	void operator()();

private:

	void test_size();
	void test_construction();
	void test_insertion();
	void test_iteration();
	void test_erase();

	/**
	 * Inserts the given number of random elements into the list.
	 */
	template <typename list>
	void fill(list& that, std::size_t numElements)
	{
		rng            gen(m_seed);
		distribution   dist(-std::numeric_limits<value_type>::max(), std::numeric_limits<value_type>::max());
		die            d(gen, dist);

		for(std::size_t i = 0; i < numElements; ++i)
			that.push_front(d());
	}

	template <typename list1, typename list2>
	void equal(list1& lhs, list2& rhs)
	{
		ASSERT_EQUAL(lhs.size(), rhs.size());

		list::iterator i    = rhs.begin();
		list::iterator end  = rhs.end();
		stdlist::iterator o = lhs.begin();

		while(i != end)
		{
			ASSERT_EQUAL(*o, *i);

			++i;
			++o;
		}
	}
};
///////////////////////////////////////////////////////////////////////////////////////////////////